Fetch Latest Version
This feature allows you to fetch the latest version of a specified npm package. In the code sample, it fetches the latest version of the 'npm' package.
const latestVersion = require('latest-version');
(async () => {
console.log(await latestVersion('npm'));
//=> '7.24.0'
})();
Fetch Latest Version with Specific Tag
This feature allows you to fetch the latest version of a specified npm package with a specific tag. In the code sample, it fetches the latest beta version of the 'npm' package.
const latestVersion = require('latest-version');
(async () => {
console.log(await latestVersion('npm', { version: 'beta' }));
//=> '8.0.0-beta.0'
})();